package com.yinhe.music.yhmusic.comment;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.adapter.TabAdapter;
import com.yinhe.music.yhmusic.base.BaseActivity;

@Deprecated
public class InfoActivity extends BaseActivity {
    private TabLayout tabLayout;
    private ViewPager viewPager;
    private TabAdapter mAdapter;
    private String titles[] = {"评论", "@我", "通知"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mv_more);
        viewPager = findViewById(R.id.viewPager);
        tabLayout = findViewById(R.id.tabs);
        setToolbar("我的消息");
        showQuickControl(true);
        setupViewPager();
    }

    private void setupViewPager() {
        tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.tab_color));
        tabLayout.setupWithViewPager(viewPager);

        // mAdapter = new TabAdapter(getSupportFragmentManager());
        // mAdapter.addFragment(new CommentFragment(),"评论");
        // mAdapter.addFragment(new CommentFragment(),"@我");
        // mAdapter.addFragment(new CommentFragment(),"通知");
        viewPager.setAdapter(mAdapter);

        for (int i = 0; i < mAdapter.getCount(); i++) {
            TabLayout.Tab tab = tabLayout.getTabAt(i);//获得每一个tab
            tab.setCustomView(R.layout.activity_info_tab);//给每一个tab设置view
            if (i == 0) {
                // 设置第一个tab的TextView是被选择的样式
                tab.getCustomView().findViewById(R.id.tv_title).setSelected(true);//第一个tab被选中
            }
            TextView textView = tab.getCustomView().findViewById(R.id.tv_title);
            textView.setText(titles[i]);//设置tab上的文字
        }
        viewPager.setOffscreenPageLimit(2);
    }
}
